"""add current_ledger_id to users table

Revision ID: 458fbd4e8913
Revises: 81d3c1b87591
Create Date: 2025-07-12 02:09:55.752578

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '458fbd4e8913'
down_revision: Union[str, None] = '81d3c1b87591'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.add_column(sa.Column('current_ledger_id', sa.Integer(), nullable=True))
        batch_op.create_foreign_key('fk_users_current_ledger_id', 'ledgers', ['current_ledger_id'], ['id'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_constraint('fk_users_current_ledger_id', type_='foreignkey')
        batch_op.drop_column('current_ledger_id')
    # ### end Alembic commands ###
